home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / M / LogoMotion101.sit / LogoMation 1.0.1 ƒ / Examples / MoveUpDown / MoveUpDown
Encoding:
Text File  |  1993-03-27  |  1.8 KB  |  88 lines  |  [UVtx/UVtl]

  1. // This program demonstrates animating a picture using
  2. // the Curve command.  While the picture is moving, the
  3. // program changes the 'move' parameter, such that at one
  4. // time the picture is moving above the background, and
  5. // at other times it is below the background.
  6.  
  7. Init()
  8.  
  9. DefPicture()
  10.  
  11. DrawRectangles()
  12.  
  13. PrepareToMove()
  14.  
  15. Curve Fx(t), 50*sin(t*(360/200)), t, -width()/2-30, width()/2+20
  16.  
  17. ////////////////////////////////////////
  18.  
  19. /////////////
  20. Function Init()
  21.     above=0
  22.     last_flip = 0
  23.  
  24. ////////////////////
  25. Function DefPicture()
  26.     Picture "MoveIt"
  27.         Fill 1,30000,40000,50000
  28.             Repeat 2
  29.                 Forward 30
  30.                 Circle 10
  31.                 Forward 1*π*10
  32.                 Straight
  33.  
  34. /////////////////////////
  35. Function DrawRectangles(x)
  36.     up
  37.     go -width()/2, -55,0
  38.     do
  39.     fil 1,64926,65535,49999
  40.         fo width()
  41.         go width()/2, -height()/2, 180
  42.         fo width()
  43.     Repeat x,-width()/2+20, width()/2-20,100
  44.         Rect(x)
  45.  
  46. ///////////////
  47. Function Rect(X)
  48.     Up
  49.     w = random(5)+5
  50.     Goto X-w,-100-last_flip*20,90
  51.     last_flip = 1 - last_flip
  52.     Down
  53.     Repeat 2
  54.         Fill 1+int(random(2)),random(60000),random(60000), random(60000)
  55.             Forward 200
  56.             Right 90
  57.             Forward 2*w
  58.             Right 90
  59.     x1 = x()
  60.     y1 = y()
  61.     fi 1,0,0,0
  62.         go x1+40,y1-20,0
  63.         fo 2*w
  64.         go x1+2*w,y1,0
  65.  
  66.             
  67. ///////////////////////////////////////            
  68. Function PrepareToMove()
  69.     Up
  70.     Pen picture="MoveIt",speed=40
  71.     Goto -width()/2-50,0,0
  72.     Down
  73.     last_flip = 0
  74.  
  75. ////////////
  76. Function Fx(X)
  77.     If last_flip = 0  // first time thru
  78.         last_flip = X
  79.         Return X
  80.     dx = X - last_flip
  81.     If (dx > 100)
  82.         last_flip = X
  83.         If above
  84.             Pen move="above"
  85.         Else
  86.             Pen move="below"
  87.         above = 1-above
  88.     Return X